/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.meteocal.EJB.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Marianna
 */
@Entity
@Table(name = "invite")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Invite.findAll", query = "SELECT i FROM Invite i"),
    @NamedQuery(name = "Invite.findById", query = "SELECT i FROM Invite i WHERE i.id = :id")})
public class Invite implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "accept")
    private boolean accept;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "invite")
    private List<InviteNotification> inviteNotificationList1;
    @JoinColumn(name = "event", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Event event;
    @JoinColumn(name = "guest", referencedColumnName = "username")
    @ManyToOne(optional = false)
    private User guest;

    public Invite() {
    }

    public Invite(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @XmlTransient
    public List<InviteNotification> getInviteNotificationList1() {
        return inviteNotificationList1;
    }

    public void setInviteNotificationList1(List<InviteNotification> inviteNotificationList1) {
        this.inviteNotificationList1 = inviteNotificationList1;
    }

    public Event getEvent() {
        return event;
    }

    public void setEvent(Event event) {
        this.event = event;
    }

    public User getGuest() {
        return guest;
    }

    public void setGuest(User guest) {
        this.guest = guest;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Invite)) {
            return false;
        }
        Invite other = (Invite) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.meteocal.EJB.entities.Invite[ id=" + id + " ]";
    }
    
    public void setAccept(boolean acc){
        this.accept= acc;
    }
    
    public boolean getAccept(){
        return accept;
    }
    
}
